package cn.doitedu.demo1;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.util.Bytes;

import java.io.IOException;
import java.util.Arrays;

public class DataGenerator {
    public static void main(String[] args) throws IOException {

        Configuration conf = HBaseConfiguration.create();
        conf.set("hbase.zookeeper.quorum","doitedu:2181");

        Connection connection = ConnectionFactory.createConnection(conf);
        Table table = connection.getTable(TableName.valueOf("user_profile"));

        Put put1 = new Put(Bytes.toBytes(1L));
        put1.addColumn(Bytes.toBytes("f"),Bytes.toBytes("tag0103"),Bytes.toBytes("A"));
        put1.addColumn(Bytes.toBytes("f"),Bytes.toBytes("tag0204"),Bytes.toBytes("A"));

        Put put2 = new Put(Bytes.toBytes(2L));
        put2.addColumn(Bytes.toBytes("f"),Bytes.toBytes("tag0103"),Bytes.toBytes("B"));
        put2.addColumn(Bytes.toBytes("f"),Bytes.toBytes("tag0204"),Bytes.toBytes("B"));


        Put put3 = new Put(Bytes.toBytes(3L));
        put3.addColumn(Bytes.toBytes("f"),Bytes.toBytes("tag0103"),Bytes.toBytes("C"));
        put3.addColumn(Bytes.toBytes("f"),Bytes.toBytes("tag0204"),Bytes.toBytes("C"));



        table.put(Arrays.asList(put1,put2,put3));


        table.close();
    }
}
